/*
 * Created by SharpDevelop.
 * User: mac
 * Date: 05.09.2006
 * Time: 18:20
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using TagTool.GraphicTypes;
using TagTool.Core;

namespace TagTool.Nodes.Graphic
{

	public class HSVColorGenerator : BaseNode
	{
		private InputSlot a;
		private InputSlot h;
		private InputSlot s;
		private InputSlot b;
		private OutputSlot color;
		
		
		public HSVColorGenerator() : base()
		{
			Name = "HSV Color";
			Color actColor = new Color();
			actColor.fromHSV(0, 1, 1, 1);
			
			a = new InputSlot(this, "Alpha", 1.0);
			a.ParseCallback = ParseHelper.ParseDouble;
			
			h = new InputSlot(this, "Hue", 0.0);
			h.ParseCallback = ParseHelper.ParseDouble;
			
			s = new InputSlot(this, "Saturation", 1.0);
			s.ParseCallback = ParseHelper.ParseDouble;
			
			b = new InputSlot(this, "Brightness", 1.0);
			b.ParseCallback = ParseHelper.ParseDouble;
	
			color = new OutputSlot(this, "Color", typeof(Color));
			color.Value = actColor;
		}
		
		public override void Update(Object sender)
		{
			color.Value = ((Color)color.Value).fromHSV((double)h.Value, (double)s.Value, (double)b.Value, (double)a.Value);
			CastTrigger();
		}
		
		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot H
		{
			get { return h; }
		}
		
		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot S
		{
			get { return s; }
		}
		
		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot B
		{
			get { return b; }
		}
		
		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot A
		{
			get { return a; }
		}

		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot Color
		{
			get { return color; }
		}
		
	}
}
